//第三方
import React,{memo} from 'react';
import {Route, Switch, Redirect, HashRouter} from "react-router-dom";
import { ConfigProvider } from 'antd';
import zh_CN from 'antd/lib/locale-provider/zh_CN'
//路由
import {adminRouters} from './router';
//组件
import { AdminLayout } from './components';
//样式
import './App.less';

export default memo(function App() {
    return (
            <ConfigProvider locale={zh_CN}>
                <HashRouter>
                <AdminLayout>
                    <Switch>
                        {
                            adminRouters.map(route => {
                                return (
                                    <Route
                                        path={route.pathname}
                                        key ={route.pathname}
                                        exact={route.exact}
                                        render={(routerProps)=> {
                                            // console.log(route);
                                            return <route.component {...routerProps}/>
                                            }
                                        }
                                        />
                                )
                            })
                        }
                        <Redirect to={adminRouters[0].pathname} from='/admin'/>
                        <Redirect to="/404"/>
                    </Switch>
                </AdminLayout>
            </HashRouter>
            </ConfigProvider>
    )
})